package net.zeus.sample.rabbitmq.routing;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import net.zeus.sample.rabbitmq.utils.ConnectionUtils;

public class RoutingSender {

	public static void main(String[] args) throws Exception{
		Connection conn = ConnectionUtils.getConnection();
		
		Channel channel = conn.createChannel();

		channel.exchangeDeclare(ConnectionUtils.EXCHANGE_DIRECT_NAME, "direct");
		
		//
		String routingKey = "error";
		
		String msg = "hello exchange direct text, routingKey-->" + routingKey;
		
		// 设置routingKey
		channel.basicPublish(ConnectionUtils.EXCHANGE_DIRECT_NAME, routingKey, null, msg.getBytes());
		
		System.out.println("send exchange msg:" + msg);
		
		channel.close();
		ConnectionUtils.closeConnection(conn);
	}

}
